
<template>
  <div class="reconciliation-withdrawFree">
    <search-table
      :url="url"
      ref="searchtable"
      :columns="columns"
      :form="form"
      :monthDate="date"
    >
      <template slot="searchForm">
        <a-form layout="inline" :form="form">
          <a-row>
            <a-form-item label="请选择月份">

              <a-month-picker
                @change="onChange"
                :format="monthFormat"
              >
              </a-month-picker>
            </a-form-item>
            <a-form-item label="请选择交易类型">
              <a-select
                showSearch
                allowClear
                style="width: 150px"
                :options="reconciliationTypeList"
                v-decorator="['type']"
                placeholder="请选择"
              >
              </a-select>
            </a-form-item>

          </a-row>
        </a-form>

      </template>

      <template slot="oprationRow">
        <permission authority="">
          <a-button type="primary" @click="exportExcel()" >导出</a-button>
        </permission>
        <!--  <permission authority="">
            <a-button style="" @click="deleteRows($refs.searchtable.selectedRowKeys)">删除</a-button>
          </permission>-->
      </template>
      <template slot="tableOperation" slot-scope="{ record }">
        <a-space>
          <!-- <permission authority="shop:user:modify"> -->
          <!---->
          <span class="text-primary pointer" @click="jumpDetail(record.id)"
          >详情</span
          >
          <!-- </permission> -->
        </a-space>
      </template>
    </search-table>
  </div>
</template>

<script>
  import SearchTable from "./components/index";
  export default {

    name: "TransactionFee",
    components:{
      SearchTable
    },
    data(){
      return{
        url: "/shop/bill/page",
        monthFormat: 'YYYY年MM月',
        // 需要传过去
        date:'',
        infoVisible: false,
        currentRecord: {},
        form: this.$form.createForm(this, { name: "table_search" }),
        columns: [
          {
            title: "时间",
            dataIndex: "billTime",
            key: "billTime",
          },
          {
            title: "类型",
            dataIndex: "type",
            key: "type",
            customRender: (text, row) => {
              switch (+text) {
                case 1:
                  return "订单入账";
                case 2:
                  return "提现";
                case 3:
                  return "退款";
              }
              // return <table-img src={text} />;
            },
          },
          {
            title: "交易名称",
            dataIndex: "name",
            key: "name",
          },
          /*   {
               title: "交易订单号",
               dataIndex: "orderNo",
               key: "orderNo",
               // colSpan: 2,
               customRender: (value, row, index) => {
                 const obj = {
                   children: value,
                   attrs: {},
                 };
                 // if (index === 2) {
                 //   obj.attrs.rowSpan = 2;
                 // }
                 // // These two are merged into above cell
                 // if (index === 3) {
                 //   obj.attrs.rowSpan = 0;
                 // }
                 // if (index === 4) {
                 // obj.attrs.colSpan = 2;
                 // }
                 return obj;
               },
             },*/
          {
            title: "交易订单号",
            dataIndex: "paymentNo",
            key: "paymentNo",
            // colSpan: 0,
          },
          {
            title: "商品名称",
            dataIndex: "account",
            key: "account",
          },
          /*       {
                   title: "收支类型",
                   dataIndex: "billType",
                   key: "billType",
                   customRender(text, row) {
                     if (text == 1) {
                       text = "收入";
                     } else if (text == 2) {
                       text = "支出";
                     } else {
                       text = "——";
                     }
                     return text;
                   },
                 },*/
          {
            title: "交易金额（元）",
            dataIndex: "shopSum",
            key: "shopSum",
            customRender(text, row) {
              return ((text * 1) / 100).toFixed(2);
            },
          },
          /*    {
                title: "支付方式",
                dataIndex: "orderPayType",
                key: "orderPayType",
                customRender: (text, row) => {
                  if (text == "1") {
                    text = "微信小程序支付";
                  }
                  return text;
                },
              },*/
          {
            title: "状态",
            dataIndex: "shopName",
            key: "shopName",
          },
          {
            title: "操作",
            dataIndex: "operation",
            scopedSlots: { customRender: "operation" },
          },
        ],
        reconciliationTypeList: [
          {
            label: "全部",
            value: 0,
          },
          {
            label: "订单入账",
            value: 1,
          },
          {
            label: "收入",
            value: 2,
          },
          {
            label: "退款",
            value: 3,
          },
        ],
      }
    },
    created() {

    },
    methods:{
      jumpDetail(id){
        console.log("详情页面")
        this.$router.push({
          path: "/money/reconciliation/detail/transactionFeeDetail",
          query:{
            id
          }
        });
      },
      exportExcel(){
       /* const params = this.$refs.searchtable.searchParams || {}
        const selectedIds = this.$refs.searchtable.selectedRowKeys
        console.log(selectedIds )
        if (selectedIds && selectedIds.length) {
          params['id'] = selectedIds.join(',')
        }
        console.log(params)
        this.$export('/order/goodsrepairs/export',params)*/
        // this.$export('/order/goodsrepairs/export', params)
      },
      onChange(date, dateString) {
        console.log(date, dateString);
        dateString = dateString.replace('年',"-")
        this.date = dateString.replace('月',"")
        console.log(this.date)
        // this.date = ""
      },
    }
  }
</script>

<style scoped>

</style>